package com.itheima.aspect;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.util.TimerTask;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * reggie-com.itheima.aspect
 * Administrator
 * 2023-03-15
 * 19:23
 */
//异步管理器:内部维护一个线程池
public class AsyncManager {
    //ScheduledExecutorService是个接口  ScheduledThreadPoolExecutor有计划的线程池执行器 核心线程数50

    private ScheduledExecutorService scheduledThreadPool=new ScheduledThreadPoolExecutor(50);


    //自定义execute(执行)方法
    //使用内部一个线程去执行具体任务
    public void execute(TimerTask task){
        //TimerTask是任务 可以传过来
        scheduledThreadPool.execute(task);

    }

}
